package com.zaofan.web.filter;

import java.io.UnsupportedEncodingException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;

public class MyServletRequest extends HttpServletRequestWrapper {

	private HttpServletRequest request;
	private HttpServletResponse response;

	public MyServletRequest(HttpServletRequest request, HttpServletResponse response) {
		super(request);
		this.request = request;
		this.response = response;
	}

	@Override
	public String getParameter(String name) {
		String value = request.getParameter(name);
		if(value == null){
			return null;
		}
		if(!request.getMethod().equalsIgnoreCase("get")){
			return value;
		}
		try {
			value = new String( value.getBytes("iso8859-1"),response.getCharacterEncoding());
			return value;
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
			throw new RuntimeException(e);
		}
		
	}
	
	

}
